package com.swancloud.openstack.networking.v20210120.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.swancloud.model.network.v20210120.ServiceProviderV2;
import com.swancloud.openstack.common.ListResult;

import java.util.List;

/**
 * A Neutron Service providers
 *
 * @author Vishvesh Deshmukh
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class NeutronServiceProviderV2 implements ServiceProviderV2 {

    private static final long serialVersionUID = 1L;

    public enum ServiceType {
        CORE, DUMMY, FIREWALL, FIREWALL_V2, FLAVORS, L3_ROUTER_NAT, LOADBALANCERV2, METERING, QOS, VPN, UNKONW;

        @JsonCreator
        public static ServiceType forValue(String value) {
            if (value != null) {
                for (ServiceType s : ServiceType.values()) {
                    if (s.name().equalsIgnoreCase(value))
                        return s;
                }
            }
            return ServiceType.UNKONW;
        }
    }

    private String name;

    @JsonProperty("default")
    private boolean enable;

    @JsonProperty("service_type")
    private String serviceType;


    @Override
    public String getName() {
        return name;
    }

    @Override
    public boolean isEnable() {
        return enable;
    }

    @Override
    public String getServiceType() {
        return serviceType;
    }


    public static class ServiceProviderV2s extends ListResult<NeutronServiceProviderV2> {

        private static final long serialVersionUID = 1L;

        @JsonProperty("service_providers")
        List<NeutronServiceProviderV2> serviceProviders;

        @Override
        public List<NeutronServiceProviderV2> value() {
            return serviceProviders;
        }

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this).omitNullValues()
                    .add("service_providers", serviceProviders).toString();
        }
    }
}
